import React, { Component } from 'react';
import { List } from '$yo-component';
import yoHistory from '$common/history';
import './index.scss';

class CommentChild extends Component {
    constructor() {
        super();
        this.state = {
          
           
        };
    }
    componentDidMount() {
       var zan = $('.zan');
       for(var i = 0 ;i<zan.lenght;i++){
           zan[i].onTouchStart=function(){
              
                alert(1);
           }
       }
    }
    render() {
        var size = this.props.size;
        
        var html = '';
        for(var i = 0;i<size;i++){
            var data = this.props.data[i];
             html += `<div className="yo">
                         <div className="top">
                            <h3>${data.address}</h3> <span className="zan">${data.zan}顶</span>
                         </div>
                         <span className="comment">${data.comment}</span>
                     </div>`
        }
        return (
            <div className="commentChild">
                {
                    this.props.title ?
                       <div className="Title" >热门跟帖</div> : <div className="Title">最新跟贴</div>
                }
                <div dangerouslySetInnerHTML={{__html:html}}/>
            </div>
        )
    }
}

CommentChild.defaultProps = {
    title: '',
    data:{

    }
}

export default CommentChild;
